package com.chen.service.impl;

import com.chen.service.AuthService;
import com.chen.util.JwtUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class AuthServiceImpl implements AuthService {
    @Autowired
    private JwtUtil jwtUtil;
    /**
     * 认证并返回token
     * @param username
     * @param password
     * @return
     */
    @Override
    public String login(String username, String password) {
        //根据用户名去数据库中查询出user对象, 然后对比密码
        //这里写假逻辑
        String userId="123";
        if ("chen".equals(username)&&"chen".equals(password)){
         return jwtUtil.generateToken(userId);
        }else {
           throw  new IllegalArgumentException("账号或者密码错误");
        }
    }
}
